define(function (require, exports, module) {

    var sTpl = require("modules/cube-list/index.html");

    var vueComponent = Vue.extend({
        template: sTpl,
        props: {
            hasOpt: {
                default: false //一般都用于查看
            },
            curCubeId: {
                default: ''
            }
        },
        data: function () {
            return {
                tableData: []
            }
        },
        methods: {
            tableRowClassName({ row, rowIndex }) {
                if (rowIndex === 1) {
                    return 'warning-row';
                } else if (rowIndex === 3) {
                    return 'success-row';
                }
                return '';
            },
            cellClick: function (row, column, cell, event) {
                if (column.property == "cnName") {
                    var config = {
                        url: '02-componentEdit.html?cubeId=' + row.id,
                        menuName: row.cnName
                    };
                    this.openWin(config);
                }

            },
            handleEditClick: function (row, type) {
                if (type == "1") {
                    var config = {
                        url: '02-componentEdit.html?cubeId=' + row.id,
                        menuName: row.cnName
                    };
                    this.openWin(config);
                }
            }
        },
        created: function () {

            var map = require("config/api.js");
            var allData = map.cub_list;

            if (this.curCubeId != "") {
                this.tableData = _.first(_.find(allData.cub_list, function (item) {
                    return item.id = this.curCubeId;
                }));
            } else {
                this.tableData = allData;
            }
            // if (this.curCubeId == "" && this.$route && this.$route.params && this.$route.params.curCubeId != "") {
            //     this.curCubeId = parseInt(this.$route.params.curCubeId) || 0;
            // }
        }
    });


    Vue.component('m-cube-list', vueComponent); //都全局注册 同时exports

    module.exports = vueComponent;
});